

//
//  HMStatusDetailView.m
//  黑马微博-wzy
//
//  Created by Mac on 2017/2/17.
//  Copyright © 2017年 Mac. All rights reserved.
//

#import "HMStatusDetailView.h"
#import "HMStatusOriginalView.h"
#import "HMStatusRetweetedView.h"
#import "HMStatusDetailFrame.h"

@interface HMStatusDetailView()

//原文
@property (nonatomic, weak) HMStatusOriginalView *originalView;
//转发
@property (nonatomic, weak) HMStatusRetweetedView *retweetedView;

@end


@implementation HMStatusDetailView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        //初始化子控件
        self.userInteractionEnabled = YES;
        self.image = [UIImage resizedImage:@"timeline_card_top_background"];
//        self.backgroundColor = [UIColor greenColor];
        //1.添加原创微博
        HMStatusOriginalView *originalView = [[HMStatusOriginalView alloc] init];
        [self addSubview:originalView];
        self.originalView = originalView;
        
        //2.添加转发微博
        HMStatusRetweetedView *retweetedView = [[HMStatusRetweetedView alloc] init];
        [self addSubview:retweetedView];
        self.retweetedView = retweetedView;
    }
    return self;
}

//根据传进来的微博数据,计算frame
//重写 detailFrame 的setter 方法
- (void)setDetailFrame:(HMStatusDetailFrame *)detailFrame{
    _detailFrame = detailFrame;
    
    self.frame = detailFrame.detailF;
    
    //1.原创微博的frame
    self.originalView.originalFrame = detailFrame.originalFrame;
    
    //2.转发微博的frame
    self.retweetedView.retweetedFrame = detailFrame.retweetedFrame;
}

@end
